package cn.com.css.taxInspection.attention.controller;

import cn.com.css.taxInspection.attention.entity.*;
import cn.com.css.taxInspection.attention.mapper.JaajxxStatuschangeMapper;
import cn.com.css.taxInspection.attention.mapper.JaajxxYjqlsjMapper;
import cn.com.css.taxInspection.attention.service.*;
import cn.com.css.taxInspection.common.aop.annotation.LogAnnotation;
import cn.com.css.taxInspection.common.constants.Constants;
import cn.com.css.taxInspection.common.constants.TaxConstants;
import cn.com.css.taxInspection.common.exception.BusinessException;
import cn.com.css.taxInspection.common.result.DataResult;
import cn.com.css.taxInspection.common.result.Result;
import cn.com.css.taxInspection.gt3.entity.*;
import cn.com.css.taxInspection.gt3.service.*;
import cn.com.css.taxInspection.system.service.impl.HttpSessionService;
import cn.com.css.taxInspection.thirdparty.service.CqyjDetailService;
import cn.com.css.taxInspection.thirdparty.service.ThirdpartyCommonService;
import cn.com.css.taxInspection.thirdparty.vo.InspectRequestData;
import cn.com.css.taxInspection.util.DateUtils;
import cn.com.css.taxInspection.util.FileUtil;
import cn.com.css.taxInspection.util.TsBqUtils;
import cn.com.css.taxInspection.workflow.entity.WorkflowActivityEntity;
import cn.com.css.taxInspection.workflow.entity.WorkflowInspectionHearEntity;
import cn.com.css.taxInspection.workflow.service.WorkflowActivityService;
import cn.com.css.taxInspection.workflow.service.WorkflowInspectionHearService;
import cn.com.css.taxInspection.workquality.vo.req.SelectchiefReqVo;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.baomidou.dynamic.datasource.annotation.DS;

import javax.validation.Valid;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;

import static cn.com.css.taxInspection.util.FileUtil.getStringCellValue;


/**
 * 专项案件管理
 */
@RequestMapping("/attention")
@RestController
@Slf4j
@RequiredArgsConstructor
@Api(tags = "关注-专项案件管理")
public class AttentionController {
    // Services
    private final AttentionService attentionService;
    private final ZbxaIndustryService zbxaIndustryService;
    private final BacklogCaseService backlogCaseService;
    private final XazbNsrCompleteService xazbNsrCompleteService;
    private final CaseAjxxRelationService caseAjxxRelationService;
    private final ZbxaXafaService zbxaXafaService;
    private final WorkflowInspectionHearService workflowInspectionHearService;
    private final WorkflowActivityService workflowActivityService;
    private final AttentionIncomeService attentionIncomeService;
    private final AjcxRecordService ajcxRecordService;
    private final CqyjDetailService cqyjDetailService;
    private final ThirdpartyCommonService thirdpartyCommonService;
    private final DmGySwryService dmGySwryService;
    private final HttpSessionService httpSessionService;
    private final DmGySwjgService dmGySwjgService;
    private final T_SWJGTMPService t_swjgtmpService;

    // Mappers
    private final JaajxxStatuschangeMapper jaajxxStatuschangeMapper;
    private final JaajxxYjqlsjMapper jaajxxYjqlsjMapper;

    // More Services
    private final JaajxxYjqlsjService jaajxxYjqlsjService;
    private final JaajxxJaxcyyService jaajxxJaxcyyService;
    private final JtjbService jtjbService;
    private final JcAjxxService jcAjxxService;
    private final JcAjglSdaylxzdService jcAjglSdaylxzdService;
    private final JcAjglSdbbService jcAjglSdbbService;
    private final AjglCljdsqcService ajglCljdsqcService;
    private final AjglCfjdsqcService ajglCfjdsqcService;
    private final AjglJctzsqcService ajglJctzsqcService;
    private final ClcfjdbbService clcfjdbbService;
    private final JcAjzxqkService jcAjzxqkService;
    private final JcCfqkcxService jcCfqkcxService;
    private final JcJjajService jcJjajService;
    private final ZbcxService zbcxService;
    private final YljaService yljaService;
    private final QtjaService qtjaService;
    private final YljamxService yljamxService;
    private final QtjamxService qtjamxService;
    private final CljamxService cljamxService;
    private final DmJcAjztService dmJcAjztService;


    @PostMapping("/specialCaseManagement/add")
    @ApiOperation(value = "新增专项案件接口")
    @LogAnnotation(title = "专项案件管理", action = "新增专项案件")
    public DataResult add(@RequestBody @Valid AttentionCase vo) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        vo.setSwjgDm(swjgDmTmp + "00");
        attentionService.addCase(vo);
        return DataResult.success();
    }

    @PostMapping("/specialCaseManagement/deleted/{id}")
    @ApiOperation(value = "删除专项案件接口")
    @LogAnnotation(title = "专项案件管理", action = "删除专项案件")
    public DataResult deleted(@PathVariable("id") String id) {
        attentionService.deletedCase(id);
        return DataResult.success();
    }

    @PostMapping("/specialCaseManagement/update")
    @ApiOperation(value = "更新专项案件接口")
    @LogAnnotation(title = "专项案件管理", action = "更新专项案件")
    public DataResult update(@RequestBody AttentionCase vo) {
        if (StringUtils.isEmpty(vo.getId())) {
            return DataResult.fail("id不能为空");
        }
        attentionService.updateCase(vo);
        return DataResult.success();
    }

    @GetMapping("/specialCaseManagement/detail/{id}")
    @ApiOperation(value = "查询专项案件详情接口")
    @LogAnnotation(title = "专项案件管理", action = "查询专项案件详情")
    public DataResult detail(@PathVariable("id") String id) {
        return DataResult.success(attentionService.detailInfo(id));
    }

    @PostMapping("/specialCaseManagement/list")
    @ApiOperation(value = "分页获取专项案件接口")
    @LogAnnotation(title = "专项案件管理", action = "分页获取专项案件")
    @SuppressWarnings({"unchecked", "rawtypes"})
    public DataResult list(@RequestBody AttentionCase vo) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        Page page = new Page(vo.getPage(), vo.getLimit());
        LambdaQueryWrapper<AttentionCase> queryWrapper = Wrappers.lambdaQuery();
        if (!StringUtils.isEmpty(vo.getStatus())) {
            queryWrapper.eq(AttentionCase::getStatus, vo.getStatus());
        }
        queryWrapper.eq(AttentionCase::getSwjgDm, swjgDmTmp + "00");
        queryWrapper.orderByAsc(AttentionCase::getCreateTime);
        return DataResult.success(attentionService.page(page, queryWrapper));
    }

    @GetMapping("/attentionCase/tree")
    @ApiOperation(value = "获取所有专项案件接口")
    @LogAnnotation(title = "专项案件管理", action = "获取所有专项案件树")
    public DataResult tree() {
        return DataResult.success(attentionService.selectAllCaseTree());
    }

    @PostMapping("/specialCaseManagement/importByajbh")
    @ApiOperation(value = "导入excel关联案件信息")
    @LogAnnotation(title = "专项案件管理", action = "导入excel关联案件信息")
    public DataResult importByajbh(@RequestParam(value = "file") MultipartFile file, String zxajId) throws IOException {
        ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
        List<List<Object>> allAjbhList = reader.read(1, reader.getRowCount());
        List<String> ajbhs = new ArrayList<>();
        for (List<Object> objects : allAjbhList) {
            for (Object object : objects) {
                ajbhs.add(String.valueOf(object).trim());
            }
        }
        List<Map<String, Object>> ajxxList = caseAjxxRelationService.getAjxxByAjbhs(ajbhs);
        //保存数据
        caseAjxxRelationService.importAjxxCaseRealtionDatas(ajxxList, zxajId);
        // 把查到的数据中的 jcajbh 提取出来，统一大小写并去空
        Set<String> foundAjbhSet = ajxxList.stream()
                .map(m -> (String) m.get("jcajbh"))
                .filter(Objects::nonNull)
                .map(String::trim)
                .collect(Collectors.toSet());
        // 原始列表也统一一下格式
        List<String> notFoundAjbhList = ajbhs.stream()
                .map(String::trim)
                .filter(ajbh -> !foundAjbhSet.contains(ajbh))
                .collect(Collectors.toList());
        List<String> foundAjbhList = new ArrayList<>(foundAjbhSet);
        //记录保存的数据
        int foundCount = foundAjbhList.size();
        int notFoundCount = notFoundAjbhList.size();
        StringBuilder message = new StringBuilder("成功导入:").append(foundCount).append("条数据！");
        if (notFoundCount > 0) {
            message.append("，<br/>未查询到的案件有").append(notFoundCount).append("条");
            // 展示未查到的编号（全部显示）
            message.append("（编号：").append(String.join(", ", notFoundAjbhList)).append("）");
        }
        message.append("！");
        return DataResult.success(message.toString());
    }

    @PostMapping("/specialCaseManagement/listajxx")
    @ApiOperation(value = "获取本地关联案件信息")
    @LogAnnotation(title = "专项案件管理", action = "获取本地关联案件信息")
    public DataResult listajxx(@RequestBody CaseAjxxRelation req) {
        Page<CaseAjxxRelation> page = new Page<>(req.getPage(), req.getLimit());
        LambdaQueryWrapper<CaseAjxxRelation> queryWrapper = Wrappers.lambdaQuery();
        if (!StringUtils.isEmpty(req.getCaseId())) {
            queryWrapper.eq(CaseAjxxRelation::getCaseId, req.getCaseId());
        }
        if (!StringUtils.isEmpty(req.getNsrmc())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrmc, req.getNsrmc());
        }
        if (!StringUtils.isEmpty(req.getNsrsbh())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrsbh, req.getNsrsbh());
        }
        if (!StringUtils.isEmpty(req.getAjbh())) {
            queryWrapper.eq(CaseAjxxRelation::getAjbh, req.getAjbh());
        }
        if (!StringUtils.isEmpty(req.getJcks()) && !"00".equals(req.getJcks())) {
            queryWrapper.eq(CaseAjxxRelation::getJcks, req.getJcks());
        }

        queryWrapper.orderByDesc(CaseAjxxRelation::getCreateTime);
        Page<CaseAjxxRelation> resPage = caseAjxxRelationService.page(page, queryWrapper);
        List<CaseAjxxRelation> records = resPage.getRecords();
        for (CaseAjxxRelation c : records) {
            String jcajxxuuid = c.getJcajxxuuid();
            WorkflowInspectionHearEntity workflowInspectionHearEntity = workflowInspectionHearService.getByJcajxxuuid(jcajxxuuid);
            c.setSjzt(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getJszt() : workflowInspectionHearEntity.getStateName());
            c.setSlry(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getSlry() : workflowInspectionHearEntity.getHearMan21());
            c.setJcks(StringUtils.isEmpty(workflowInspectionHearEntity) ? getSwjgMcBySwjgDm(c.getJcks()) : getSwjgMcBySwjgDm(workflowInspectionHearEntity.getInspectionTaxorg11()));
            c.setAjbh(c.getAjbh() + "\t");
            c.setNsrsbh(c.getNsrsbh() + "\t");
            //2024-1-29 11:34:18 处理立案天数
            String ajztDm = c.getAjztDm();
            if (!ajztDm.startsWith("5") && TsBqUtils.isNotNull(ajztDm)) {
                Long aLong = TsBqUtils.calcMergeDays(DateUtils.date2String(c.getLarq(), DateUtils.DATE_DEFAULT_FORMAT), DateUtils.date2String(new Date(), DateUtils.DATE_DEFAULT_FORMAT));
                c.setLats(aLong);
            }
            //2024-1-29 11:34:34处理查补额 入库额
            AjcxRecord ajcxRecordByJcajbh = ajcxRecordService.getAjcxRecordByJcajbh(c.getAjbh().replace("\t", ""));
            if (TsBqUtils.isNotNull(ajcxRecordByJcajbh)) {
                c.setAjjcztDm(dmJcAjztService.getAjztmcByajjcztDm(ajcxRecordByJcajbh.getAjjcztDm()));
                c.setCbe(ajcxRecordByJcajbh.getCbse());
                c.setRke(ajcxRecordByJcajbh.getRkse());
                c.setJcks(dmGySwjgService.getSwjgDmBySwjgJc(ajcxRecordByJcajbh.getJcbmDm()));
            }
        }
        resPage.setRecords(records);
        return DataResult.success(resPage);
    }

    @PostMapping("/specialCaseManagement/exportZxaj")
    @ApiOperation(value = "获取本地关联案件信息")
    @LogAnnotation(title = "专项案件管理", action = "获取本地关联案件信息")
    public DataResult exportZxaj(@RequestBody CaseAjxxRelation req) {
        LambdaQueryWrapper<CaseAjxxRelation> queryWrapper = Wrappers.lambdaQuery();
        if (!StringUtils.isEmpty(req.getCaseId())) {
            queryWrapper.eq(CaseAjxxRelation::getCaseId, req.getCaseId());
        }
        if (!StringUtils.isEmpty(req.getNsrmc())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrmc, req.getNsrmc());
        }
        if (!StringUtils.isEmpty(req.getNsrsbh())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrsbh, req.getNsrsbh());
        }
        if (!StringUtils.isEmpty(req.getAjbh())) {
            queryWrapper.eq(CaseAjxxRelation::getAjbh, req.getAjbh());
        }
        if (!StringUtils.isEmpty(req.getJcks()) && !"00".equals(req.getJcks())) {
            queryWrapper.eq(CaseAjxxRelation::getJcks, req.getJcks());
        }
        queryWrapper.orderByDesc(CaseAjxxRelation::getCreateTime);
        List<CaseAjxxRelation> records = caseAjxxRelationService.list(queryWrapper);
        for (CaseAjxxRelation c : records) {
            String jcajxxuuid = c.getJcajxxuuid();
            WorkflowInspectionHearEntity workflowInspectionHearEntity = workflowInspectionHearService.getByJcajxxuuid(jcajxxuuid);
            c.setSjzt(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getJszt() : workflowInspectionHearEntity.getStateName());
            c.setSlry(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getSlry() : workflowInspectionHearEntity.getHearMan21());
            c.setJcks(StringUtils.isEmpty(workflowInspectionHearEntity) ? getSwjgMcBySwjgDm(c.getJcks()) : getSwjgMcBySwjgDm(workflowInspectionHearEntity.getInspectionTaxorg11()));
            c.setAjbh(c.getAjbh() + "\t");
            c.setNsrsbh(c.getNsrsbh() + "\t");
            //2024-1-29 11:34:18 处理立案天数
            String ajztDm = c.getAjztDm();
            if (!ajztDm.startsWith("5") && TsBqUtils.isNotNull(ajztDm)) {
                Long aLong = TsBqUtils.calcMergeDays(DateUtils.date2String(c.getLarq(), DateUtils.DATE_DEFAULT_FORMAT), DateUtils.date2String(new Date(), DateUtils.DATE_DEFAULT_FORMAT));
                c.setLats(aLong);
            }
            //2024-1-29 11:34:34处理查补额 入库额
            AjcxRecord ajcxRecordByJcajbh = ajcxRecordService.getAjcxRecordByJcajbh(c.getAjbh().replace("\t", ""));
            if (TsBqUtils.isNotNull(ajcxRecordByJcajbh)) {
                c.setAjjcztDm(dmJcAjztService.getAjztmcByajjcztDm(ajcxRecordByJcajbh.getAjjcztDm()));
                c.setCbe(ajcxRecordByJcajbh.getCbse());
                c.setRke(ajcxRecordByJcajbh.getRkse());
                c.setJcks(dmGySwjgService.getSwjgDmBySwjgJc(ajcxRecordByJcajbh.getJcbmDm()));
            }
        }
        return DataResult.success(records);
    }

    private String getSwjgMcBySwjgDm(String swjgDm) {
        if (StringUtils.isEmpty(swjgDm)) {
            swjgDm = "0";
        }
        String swjgMc = "";
        switch (swjgDm) {
            case "12101009141":
                swjgMc = "检查一科";
                break;
            case "12101009142":
                swjgMc = "检查二科";
                break;
            case "12101009143":
                swjgMc = "检查三科";
                break;
            case "12101009144":
                swjgMc = "检查四科";
                break;
            case "12101009145":
                swjgMc = "检查五科";
                break;
        }
        return swjgMc;
    }


    @PostMapping("/downloadZxajmx_mb")
    @LogAnnotation(title = "专项管理", action = "专项案件明细模板下载")
    public ResponseEntity<Resource> downloadZxajmx_mb() {
        InputStream inputStream = getClass().getClassLoader().getResourceAsStream("templates/excel/专项案件明细模板.xlsx");

        if (inputStream == null) {
            throw new RuntimeException("模板文件找不到！");
        }

        InputStreamResource resource = new InputStreamResource(inputStream);

        return ResponseEntity.ok()
                .contentType(MediaType.APPLICATION_OCTET_STREAM)
                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=专项案件明细模板.xlsx")
                .body(resource);
    }


    @PostMapping("/inputZxaj_mb")
    @LogAnnotation(title = "专项管理", action = "导入专项案件")
    public DataResult inputZxaj_mb(@RequestParam(value = "file") MultipartFile file, String zxajId) throws IOException {
        ExcelReader reader = ExcelUtil.getReader(file.getInputStream());

        if (file.isEmpty() || file.getOriginalFilename() == null) {
            return DataResult.error(("上传的文件为空！"));
        }

        List<List<Object>> allAjbhList = reader.read(1, reader.getRowCount());
        List<String> ajbhs = new ArrayList<>();
        for (List<Object> objects : allAjbhList) {
            for (Object object : objects) {
                ajbhs.add(String.valueOf(object).trim());
            }
        }

        if (ajbhs.isEmpty()) {
            return DataResult.error("Excel 内容为空，至少需要包含一行数据！");
        }
        List<Map<String, Object>> ajxxList = caseAjxxRelationService.getAjxxByAjbhs(ajbhs);
        //保存数据
        caseAjxxRelationService.importAjxxCaseRealtionDatas(ajxxList, zxajId);
        // 把查到的数据中的 jcajbh 提取出来，统一大小写并去空
        Set<String> foundAjbhSet = ajxxList.stream()
                .map(m -> (String) m.get("jcajbh"))
                .filter(Objects::nonNull)
                .map(String::trim)
                .collect(Collectors.toSet());
        // 原始列表也统一一下格式
        List<String> notFoundAjbhList = ajbhs.stream()
                .map(String::trim)
                .filter(ajbh -> !foundAjbhSet.contains(ajbh))
                .collect(Collectors.toList());
        List<String> foundAjbhList = new ArrayList<>(foundAjbhSet);
        //记录保存的数据
        int foundCount = foundAjbhList.size();
        int notFoundCount = notFoundAjbhList.size();

        Map<String, Object> map = new HashMap<>();
        map.put("validDataCount", foundCount);
        map.put("errorDataCount", notFoundCount);
        return DataResult.success(map);
    }

    @PostMapping("/inputZxajmx_mb")
    @LogAnnotation(title = "专项管理", action = "导入专项案件明细")
    public ResponseEntity<?> inputZxajmx_mb(@RequestParam(value = "file") MultipartFile file) throws IOException {
        if (file == null || file.isEmpty() || file.getOriginalFilename() == null) {
            return ResponseEntity.ok(Result.error("上传的文件为空！"));
        }

        Workbook workbook = new XSSFWorkbook(file.getInputStream());
        Sheet sheet = workbook.getSheetAt(0);
        if (sheet == null || sheet.getPhysicalNumberOfRows() <= 1) {
            workbook.close();
            return ResponseEntity.ok(Result.error("Excel 内容为空，至少需要包含一行数据！"));
        }
        int validDataCount = 0;
        int errorDataCount = 0;

        for (Row row : sheet) {
            if (row.getRowNum() < 1 || FileUtil.isRowEmpty(row)) continue;
            // 组装数据
            CaseAjxxRelation caseAjxxRelation = new CaseAjxxRelation();
            caseAjxxRelation.setAjbh(getStringCellValue(row.getCell(0)));
            caseAjxxRelation.setXpnd(getStringCellValue(row.getCell(1)));
            caseAjxxRelation.setDbcj(getStringCellValue(row.getCell(2)));
            caseAjxxRelation.setAjssdl(getStringCellValue(row.getCell(3)));
            caseAjxxRelation.setAymc(getStringCellValue(row.getCell(4)));
            if (caseAjxxRelationService.updateZxajmxByAjbh(caseAjxxRelation) > 0) {
                validDataCount += 1;
            } else {
                errorDataCount += 1;
            }
        }
        workbook.close();
        if (validDataCount == 0) {
            return ResponseEntity.ok(Result.error("Excel 中没有有效的数据行！"));
        }
        Map<String, Object> map = new HashMap<>();
        map.put("validDataCount", validDataCount);
        map.put("errorDataCount", errorDataCount);
        return ResponseEntity.ok(Result.success(map));
    }


    @PostMapping("/attentionMgr/saveAyzd/{addZdmc}")
    @ApiOperation(value = "双打案源类型字典")
    @LogAnnotation(title = "双打案源类型字典", action = "保存双打案源类型字典")
    public DataResult saveAyzd(@PathVariable("addZdmc") String addZdmc) {
        JcAjglSdaylxzdEntity jcAjglSdaylxzdEntity = new JcAjglSdaylxzdEntity();
        jcAjglSdaylxzdEntity.setUuid(TsBqUtils.getUUID());
        jcAjglSdaylxzdEntity.setZdmc(addZdmc);
        jcAjglSdaylxzdEntity.setCjrdm(httpSessionService.getCurrentUsername());
        jcAjglSdaylxzdEntity.setCjrmc(dmGySwryService.getSwry(httpSessionService.getCurrentUsername()).getSwryxm());
        jcAjglSdaylxzdEntity.setCjsj(DateUtils.getCurrentDate());
        jcAjglSdaylxzdEntity.setYxbz(Constants.AJZT_LX_Y);
        jcAjglSdaylxzdService.save(jcAjglSdaylxzdEntity);
        return DataResult.success();
    }

    @PostMapping("/attentionMgr/saveAyzdStatus/")
    @ApiOperation(value = "保存双打案源类型字典状态")
    @LogAnnotation(title = "保存双打案源类型字典状态", action = "保存双打案源类型字典状态")
    public DataResult saveAyzdStatus(@RequestBody Map<String, String> params) {
        JcAjglSdaylxzdEntity jcAjglSdaylxzdEntity = new JcAjglSdaylxzdEntity();
        jcAjglSdaylxzdEntity.setUuid(params.get("id"));
        jcAjglSdaylxzdEntity.setYxbz(params.get("yxbz"));
        jcAjglSdaylxzdService.updateById(jcAjglSdaylxzdEntity);
        return DataResult.success();
    }

    @PostMapping("/specialCaseManagement/deletedajxx/{id}")
    @ApiOperation(value = "删除专项案件接口")
    @LogAnnotation(title = "专项案件管理", action = "删除专项案件")
    public DataResult deletedajxx(@PathVariable("id") String id) {
        caseAjxxRelationService.deletedCaseAjxxRelation(id);
        return DataResult.success();
    }


    @PostMapping("/specialCaseManagement/pldeletedajxx/{ids}")
    @ApiOperation(value = "批量删除专项案件关联案件接口")
    @LogAnnotation(title = "专项案件管理", action = "批量删除专项案件关联案件接口")
    public DataResult pldeletedajxx(@PathVariable("ids") String ids) {
        ids = ids.substring(0, ids.length() - 1);
        List<String> idList = Arrays.asList(ids.split(","));
        caseAjxxRelationService.pldeletedCaseAjxxRelation(idList);
        return DataResult.success();
    }


    @PostMapping("/attentionCase/flowRecord")
    @ApiOperation(value = "分页获取专项案件流转记录")
    @LogAnnotation(title = "关注案件", action = "分页获取专项案件流转记录")
    public DataResult lzjl(@RequestBody WorkflowActivityEntity workflowActivityEntity) {
        String jcajxxuuid = workflowActivityEntity.getRelevance();
        LambdaQueryWrapper<WorkflowActivityEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(WorkflowActivityEntity::getRelevance, jcajxxuuid);
        queryWrapper.orderByDesc(WorkflowActivityEntity::getCreateTime);
        List<WorkflowActivityEntity> list = workflowActivityService.list(queryWrapper);
        for (WorkflowActivityEntity activity : list) {
            activity.setRemark("系统流程");
        }
        // 查询金三流程
        List<WorkflowActivityEntity> gt3List = workflowActivityService.getGt3Workflow(jcajxxuuid);
        if (TsBqUtils.isNotNull(gt3List)) {
            list.addAll(gt3List);
        }
        JcAjxxEntity jcAjxxEntity = jcAjxxService.getByJcajxxuuid(jcajxxuuid);
        //将整个list转换为流转记录显示的
        List<FlowRecord> flowRecords = new ArrayList<>();
        FlowRecord flowRecord;
        for (WorkflowActivityEntity activity : list) {
            flowRecord = new FlowRecord();
            flowRecord.setBz(activity.getContent());
            flowRecord.setCategory(activity.getStateName());
            String czryDm = activity.getCurrentMan();
            if (TsBqUtils.isNotNull(czryDm)) {
                DmGySwryEntity zcSwry = dmGySwryService.getSwry(czryDm);
                czryDm = zcSwry.getSwryxm() + "|" + czryDm;
            }
            flowRecord.setCzr(czryDm);
            flowRecord.setCzsj(activity.getCreateTime());
            flowRecord.setDate(activity.getCreateTime());
            flowRecord.setNsrmc(String.valueOf(jcAjxxEntity.getNsrmc()));
            flowRecord.setAjbh(String.valueOf(jcAjxxEntity.getJcajbh()));
            flowRecords.add(flowRecord);
        }

        flowRecords.sort((t1, t2) -> t2.getDate().compareTo(t1.getDate()));
        return DataResult.success(flowRecords);
    }


    @PostMapping("/attentionCase/logRecord")
    @ApiOperation(value = "分页获取专项案件日志记录")
    @LogAnnotation(title = "关注案件", action = "分页获取专项案件日志记录")
    public DataResult logRecord(@RequestBody WorkflowActivityEntity workflowActivityEntity) {
        String jcajxxuuid = workflowActivityEntity.getRelevance();
        return DataResult.success(attentionIncomeService.logRecord(jcajxxuuid));
    }

    @PostMapping("/attentionInfome/incomelist")
    @ApiOperation(value = "分页获取关注收入")
    @LogAnnotation(title = "关注收入", action = "分页获取关注收入")
    @SuppressWarnings({"unchecked", "rawtypes"})
    public DataResult incomelist(@RequestBody IncomeCondition vo) {
        //默认查不出数据
        String loadOrNOT = vo.getLoadOrNOT();
        if ("0".equals(loadOrNOT)) {
            return DataResult.success();
        }
        Page page = new Page();
        Map<String, Object> resMap = attentionIncomeService.incomeList(vo);
        page.setRecords((List<Income>) resMap.get("incomes"));
        page.setTotal(Long.parseLong(String.valueOf(resMap.get("incomesTotal"))));
        page.setCurrent(vo.getPage());
        return DataResult.success(page);
    }

    @PostMapping("/attentionInfome/incomelistForExport")
    @ApiOperation(value = "导出关注收入所有数据")
    @LogAnnotation(title = "导出关注收入所有数据", action = "导出关注收入所有数据")
    public DataResult incomelistForExport(@RequestBody IncomeCondition vo) {
        Map<String, Object> resMap = attentionIncomeService.incomelistForExport(vo);
        return DataResult.success(resMap.get("incomes"));
    }

    @PostMapping("/attentionMgr/ajcx")
    @ApiOperation(value = "案件管理-案件查询")
    @LogAnnotation(title = "案件管理-案件查询", action = "案件管理-案件查询")
    @SuppressWarnings({"rawtypes"})
    public DataResult ajcx(@RequestBody AjcxCondition req) throws ParseException {
        Page resPage = ajcxRecordService.getAjcxRecordPage(req);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/exportAjcx")
    @ApiOperation(value = "案件管理-案件导出")
    @LogAnnotation(title = "案件管理-案件导出", action = "案件管理-案件导出")
    public DataResult exportAjcx(@RequestBody AjcxCondition req) throws ParseException {
        List<AjcxRecord> records = ajcxRecordService.exportAjcxRecord(req);
        return DataResult.success(records);
    }

    @PostMapping("/attentionMgr/queryAjwhTable")
    @ApiOperation(value = "案件管理-案件维护")
    @LogAnnotation(title = "案件管理-案件维护", action = "案件维护列表查询")
    public DataResult queryAjwhTable(@RequestBody JcAjglSdbbEntity jcAjglSdbbEntity) throws ParseException {
        IPage<JcAjglSdbbEntity> resPage = jcAjglSdbbService.getJcAjglSdbbPage(jcAjglSdbbEntity);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/exportAjwhTable")
    @ApiOperation(value = "案件管理")
    @LogAnnotation(title = "案件管理-案件维护", action = "导出案件维护列表查询")
    public DataResult exportAjwhTable(@RequestBody JcAjglSdbbEntity jcAjglSdbbEntity) throws ParseException {
        List<JcAjglSdbbEntity> jcAjglSdbbEntityList = jcAjglSdbbService.exportJcAjglSdbbPage(jcAjglSdbbEntity);
        return DataResult.success(jcAjglSdbbEntityList);
    }

    @PostMapping("/attentionMgr/querySdaylxzdTable")
    @ApiOperation(value = "案件管理-案件查询")
    @LogAnnotation(title = "案件管理-案件查询", action = "案件管理-案件查询")
    public DataResult querySdaylxzdTable(@RequestBody JcAjglSdaylxzdEntity jcAjglSdaylxzdEntity) throws ParseException {
        IPage<JcAjglSdaylxzdEntity> resPage = jcAjglSdaylxzdService.getSdaylxzdPage(jcAjglSdaylxzdEntity);
        return DataResult.success(resPage);
    }

    @ApiOperation(value = "案件管理-获取案源管理字典列表")
    @LogAnnotation(title = "案件管理", action = "获取案源管理字典列表")
    @PostMapping("/attentionMgr/queryAylxzdList")
    @ResponseBody
   
    public DataResult queryAylxzdList() {
        List<JcAjglSdaylxzdEntity> list = jcAjglSdaylxzdService.list();
        list = list.stream()
                .sorted(Comparator.comparing(JcAjglSdaylxzdEntity::getCjsj)) // 升序
                .collect(Collectors.toList());
        return DataResult.success(list);
    }

    @ApiOperation(value = "案件管理-保存案件维护-双打报表信息")
    @LogAnnotation(title = "案件管理", action = "保存案件维护-双打报表信息")
    @PostMapping("/attentionMgr/saveAjwhxxList")
    @ResponseBody
   
    public DataResult saveAjwhxxList(@RequestBody JcAjglSdbbEntity jcAjglSdbbEntity) {
        Boolean result = jcAjglSdbbService.updateById(jcAjglSdbbEntity);
        return DataResult.success(result);
    }

    @PostMapping("/clerkIndexBjaj")
    @ApiOperation(value = "检查人首页-办结案件")
    @LogAnnotation(title = "检查人首页-办结案件", action = "检查人首页-办结案件")
    public DataResult clerkIndexBjaj(@RequestBody AjcxCondition req) throws ParseException {
        return DataResult.success(ajcxRecordService.getClerkIndexBjajPage(req));
    }

    @PostMapping("/clerkIndexAjcount")
    @ApiOperation(value = "检查人首页-各种案件数量")
    @LogAnnotation(title = "检查人首页-各种案件数量", action = "检查人首页-各种案件数量")
    public DataResult clerkIndexAjcount() {
        Map<String, Object> resMap = new HashMap<>();
        Map<String, Object> gt3AjCountMap = ajcxRecordService.getClerkIndexAjcountGt3();
        Map<String, Object> xzsAjCountMap = ajcxRecordService.getClerkIndexAjcountXzs();
        resMap.put("kzspajs", xzsAjCountMap.get("KZSPAJS"));
        resMap.put("jzspajs", xzsAjCountMap.get("JZSPAJS"));
        resMap.put("zsbsajs", xzsAjCountMap.get("ZSBSAJS"));
        resMap.put("zcajs", gt3AjCountMap.get("ZCAJS"));
        resMap.put("bntsajs", gt3AjCountMap.get("BNTSAJS"));
        resMap.put("bcjcajs", gt3AjCountMap.get("BCJCAJS"));
        resMap.put("bnsjajs", gt3AjCountMap.get("BNSJAJS"));
        resMap.put("zzjcajs", gt3AjCountMap.get("ZZ JCAJS"));
        return DataResult.success(resMap);
    }

    @PostMapping("/initRightTenCaseCount")
    @ApiOperation(value = "局长首页-右侧各种案件数量")
    @LogAnnotation(title = "局长首页-右侧各种案件数量", action = "局长首页-右侧各种案件数量")
    public DataResult initRightTenCaseCount() {
        return DataResult.success(ajcxRecordService.initRightTenCaseCount());
    }

    @PostMapping("/initTopJajzTips")
    @ApiOperation(value = "局长首页-积案进展右上角数量")
    @LogAnnotation(title = "局长首页-积案进展右上角数量", action = "局长首页-积案进展右上角数量")
    public DataResult initTopJajzTips() {
        return DataResult.success(ajcxRecordService.initTopJajzTips());
    }

    @PostMapping("/cqyjdetail")
    @ApiOperation(value = "案件预警")
    @LogAnnotation(title = "案件预警", action = "案件预警")
    public DataResult cqyjdetail(@RequestBody InspectRequestData req) {
        return DataResult.success(cqyjDetailService.getCqyjDetailDataForXzs(req));
    }

    @PostMapping("/dchsdetail")
    @ApiOperation(value = "调查核实")
    @LogAnnotation(title = "调查核实", action = "调查核实")
    public DataResult dchsdetail(@RequestBody InspectRequestData req) {
        return DataResult.success(thirdpartyCommonService.doGetDchsXzDataForXzs(req));
    }

    @PostMapping("/jaqkdetail")
    @ApiOperation(value = "积案情况")
    @LogAnnotation(title = "积案情况", action = "积案情况")
    public DataResult jaqkdetail(@RequestBody InspectRequestData req) {
        return DataResult.success(thirdpartyCommonService.doGetJaqkXzDataForXzs(req));
    }

    @PostMapping("/backlogCaseManagement/list")
    @ApiOperation(value = "分页获取一类和二类积案")
    @LogAnnotation(title = "积案管理", action = "分页获取一类和二类积案")
//   
    @SuppressWarnings({"unchecked", "rawtypes"})
    public DataResult backlogCaseManagement_list(@RequestBody BacklogCase vo) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        Page page = new Page(vo.getPage(), vo.getLimit());
        LambdaQueryWrapper<BacklogCase> queryWrapper = Wrappers.lambdaQuery();
        if (!StringUtils.isEmpty(vo.getStatus())) {
            queryWrapper.eq(BacklogCase::getStatus, vo.getStatus());
        }
        queryWrapper.eq(BacklogCase::getSwjgDm, swjgDmTmp + "00");
        return DataResult.success(backlogCaseService.page(page, queryWrapper));
    }


    @PostMapping("/backlogCaseManagement/queryYljaTable")
    @ApiOperation(value = "查询一类积案")
    @LogAnnotation(title = "积案管理", action = "查询一类积案")
   
    public DataResult queryYljaTable(@RequestBody YljaEntity yljaEntity) throws ParseException {
        return DataResult.success(yljaService.queryYljaTable(yljaEntity));
    }

    @PostMapping("/backlogCaseManagement/queryQtjaTable")
    @ApiOperation(value = "查询其他积案")
    @LogAnnotation(title = "积案管理", action = "查询其他积案")
   
    public DataResult queryQtjaTable(@RequestBody QtjaEntity qtjaEntity) throws ParseException {
        return DataResult.success(qtjaService.queryQtjaTable(qtjaEntity));
    }

    @PostMapping("/backlogCaseManagement/queryYljamxTable")
    @ApiOperation(value = "查询一类积案明细")
    @LogAnnotation(title = "积案管理", action = "查询一类积案明细")
   
    public DataResult queryYljamxTable(@RequestBody YljamxEntity yljamxEntity) throws ParseException {
        return DataResult.success(yljamxService.queryYljamxTable(yljamxEntity));
    }

    @PostMapping("/backlogCaseManagement/queryQtjamxTable")
    @ApiOperation(value = "查询其他积案明细")
    @LogAnnotation(title = "积案管理", action = "查询其他积案明细")
   
    public DataResult queryQtjamxTable(@RequestBody QtjamxEntity QtjamxEntity) throws ParseException {
        return DataResult.success(qtjamxService.queryQtjamxTable(QtjamxEntity));
    }

    @PostMapping("/backlogCaseManagement/queryCljamxTable")
    @ApiOperation(value = "查询超六积案明细")
    @LogAnnotation(title = "积案管理", action = "查询超六积案明细")
   
    public DataResult queryCljamxTable(@RequestBody CljamxEntity CljamxEntity) throws ParseException {
        return DataResult.success(cljamxService.queryCljamxTable(CljamxEntity));
    }

    @PostMapping("/backlogCaseManagement/exportYljaTable")
    @ApiOperation(value = "导出一类积案")
    @LogAnnotation(title = "积案管理", action = "导出一类积案")
   
    public DataResult exportYljaTable(@RequestBody YljaEntity yljaEntity) throws ParseException {
        return DataResult.success(yljaService.exportYljaTable(yljaEntity));
    }

    @PostMapping("/backlogCaseManagement/exportQtjaTable")
    @ApiOperation(value = "导出其他积案")
    @LogAnnotation(title = "积案管理", action = "导出其他积案")
   
    public DataResult exportQtjaTable(@RequestBody QtjaEntity qtjaEntity) throws ParseException {
        return DataResult.success(qtjaService.exportQtjaTable(qtjaEntity));
    }


    @PostMapping("/backlogCaseManagement/add")
    @ApiOperation(value = "新增专项案件接口")
    @LogAnnotation(title = "积案管理", action = "新增专项案件")
    public DataResult backlogCaseManagement_add(@RequestBody @Valid BacklogCase vo) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        vo.setSwjgDm(swjgDmTmp + "00");
        backlogCaseService.addCase(vo);
        return DataResult.success();
    }

    @PostMapping("/backlogCaseManagement/deleted/{id}")
    @ApiOperation(value = "删除专项案件接口")
    @LogAnnotation(title = "积案管理", action = "删除专项案件")
    public DataResult backlogCaseManagement_deleted(@PathVariable("id") String id) {
        backlogCaseService.deletedCase(id);
        return DataResult.success();
    }

    @PostMapping("/backlogCaseManagement/update")
    @ApiOperation(value = "更新专项案件接口")
    @LogAnnotation(title = "积案管理", action = "更新专项案件")
    public DataResult backlogCaseManagement_update(@RequestBody BacklogCase vo) {
        if (StringUtils.isEmpty(vo.getId())) {
            return DataResult.fail("id不能为空");
        }
        backlogCaseService.updateCase(vo);
        return DataResult.success();
    }

    @GetMapping("/backlogCaseManagement/detail/{id}")
    @ApiOperation(value = "查询专项案件详情接口")
    @LogAnnotation(title = "积案管理", action = "查询专项案件详情")
    public DataResult backlogCaseManagement_detail(@PathVariable("id") String id) {
        return DataResult.success(backlogCaseService.detailInfo(id));
    }


    @GetMapping("/backlogCaseManagement/tree")
    @ApiOperation(value = "获取所有专项案件接口")
    @LogAnnotation(title = "专项案件管理", action = "获取所有专项案件树")
    public DataResult backlogCaseManagement_tree() {
        return DataResult.success(backlogCaseService.selectAllCaseTree());
    }


    @PostMapping("/backlogCaseManagement/listFirstajxx")
    @ApiOperation(value = "一类积案")
    @LogAnnotation(title = "一类积案", action = "一类积案")
   
    @SuppressWarnings({"unchecked", "rawtypes"})
    public DataResult listFirstajxx(@RequestBody CaseAjxxRelation req) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        String paramSwjgDm = req.getSwjgDm();
        Page page = new Page(req.getPage(), req.getLimit());
        LambdaQueryWrapper<CaseAjxxRelation> queryWrapper = Wrappers.lambdaQuery();
        if (!StringUtils.isEmpty(req.getCaseId()) && !"qs".equals(req.getJcks())) {
            queryWrapper.eq(CaseAjxxRelation::getCaseId, TsBqUtils.getCaseIdBySwjgDmAndLevel(swjgDmTmp, "1"));
        }
        if (!StringUtils.isEmpty(req.getNsrmc())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrmc, req.getNsrmc());
        }
        if (!StringUtils.isEmpty(req.getNsrsbh())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrsbh, req.getNsrsbh());
        }
        if (!StringUtils.isEmpty(req.getAjbh())) {
            queryWrapper.eq(CaseAjxxRelation::getAjbh, req.getAjbh());
        }
        String jcks = req.getJcks();
        if (StringUtils.hasText(jcks) && !"00".equals(jcks) && !"qs".equals(jcks)) {
            queryWrapper.eq(CaseAjxxRelation::getJcks, jcks);
        }
        String ajztDm = req.getAjztDm();
        if (!"0".equals(ajztDm)) {
            if ("901".equals(ajztDm)) {
                queryWrapper.eq(CaseAjxxRelation::getAjztDm, ajztDm);
            } else {
                queryWrapper.likeRight(CaseAjxxRelation::getAjztDm, ajztDm);
            }
        }
        //等于0 是功能进来的 不等于0 则是通过积案页面跳转过来的
        if (!"qs".equals(req.getJcks())) {
            String likeValue = "0".equals(paramSwjgDm) ? swjgDmTmp : paramSwjgDm.substring(0, 9);
            queryWrapper.likeRight(CaseAjxxRelation::getJcks, likeValue);
        }
        queryWrapper.orderByDesc(CaseAjxxRelation::getLarq, CaseAjxxRelation::getCreateTime);
        Page resPage = caseAjxxRelationService.page(page, queryWrapper);
        List<CaseAjxxRelation> records = resPage.getRecords();
        for (CaseAjxxRelation c : records) {
            String jcajxxuuid = c.getJcajxxuuid();
            WorkflowInspectionHearEntity workflowInspectionHearEntity = workflowInspectionHearService.getByJcajxxuuid(jcajxxuuid);
            c.setSjzt(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getJszt() : workflowInspectionHearEntity.getStateName());
            c.setSlry(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getSlry() : workflowInspectionHearEntity.getHearMan21());
            c.setJcks(StringUtils.isEmpty(workflowInspectionHearEntity) ? getSwjgMcBySwjgDm(c.getJcks()) : getSwjgMcBySwjgDm(workflowInspectionHearEntity.getInspectionTaxorg11()));
            c.setAjbh(c.getAjbh() + "\t");
            c.setNsrsbh(c.getNsrsbh() + "\t");
        }
        resPage.setRecords(records);
        return DataResult.success(resPage);
    }

    @PostMapping("/backlogCaseManagement/listSecondajxx")
    @ApiOperation(value = "二类积案")
    @LogAnnotation(title = "二类积案", action = "二类积案")
    @SuppressWarnings({"unchecked", "rawtypes"})
   
    public DataResult listSecondajxx(@RequestBody CaseAjxxRelation req) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        String paramSwjgDm = req.getSwjgDm();
        Page page = new Page(req.getPage(), req.getLimit());
        LambdaQueryWrapper<CaseAjxxRelation> queryWrapper = Wrappers.lambdaQuery();
        if (!StringUtils.isEmpty(req.getCaseId())) {
            queryWrapper.eq(CaseAjxxRelation::getCaseId, TsBqUtils.getCaseIdBySwjgDmAndLevel(swjgDmTmp, "2"));
        }
        if (!StringUtils.isEmpty(req.getNsrmc())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrmc, req.getNsrmc());
        }
        if (!StringUtils.isEmpty(req.getNsrsbh())) {
            queryWrapper.eq(CaseAjxxRelation::getNsrsbh, req.getNsrsbh());
        }
        if (!StringUtils.isEmpty(req.getAjbh())) {
            queryWrapper.eq(CaseAjxxRelation::getAjbh, req.getAjbh());
        }
        if (!StringUtils.isEmpty(req.getJcks()) && !"00".equals(req.getJcks())) {
            queryWrapper.eq(CaseAjxxRelation::getJcks, req.getJcks());
        }
        String ajztDm = req.getAjztDm();
        if (!"0".equals(ajztDm)) {
            if ("901".equals(ajztDm)) {
                queryWrapper.eq(CaseAjxxRelation::getAjztDm, ajztDm);
            } else {
                queryWrapper.likeRight(CaseAjxxRelation::getAjztDm, ajztDm);
            }
        }
        if ("0".equals(paramSwjgDm)) {//等于0 是功能进来的 不等于0 则是通过积案页面跳转过来的
            queryWrapper.likeRight(CaseAjxxRelation::getJcks, swjgDmTmp);
        } else {
            queryWrapper.likeRight(CaseAjxxRelation::getJcks, paramSwjgDm.substring(0, 9));
        }
        queryWrapper.orderByDesc(CaseAjxxRelation::getLarq, CaseAjxxRelation::getCreateTime);
        Page resPage = caseAjxxRelationService.page(page, queryWrapper);
        List<CaseAjxxRelation> records = resPage.getRecords();
        for (CaseAjxxRelation c : records) {
            String jcajxxuuid = c.getJcajxxuuid();
            WorkflowInspectionHearEntity workflowInspectionHearEntity = workflowInspectionHearService.getByJcajxxuuid(jcajxxuuid);
            c.setSjzt(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getJszt() : workflowInspectionHearEntity.getStateName());
            c.setSlry(StringUtils.isEmpty(workflowInspectionHearEntity) ? c.getSlry() : workflowInspectionHearEntity.getHearMan21());
            c.setJcks(StringUtils.isEmpty(workflowInspectionHearEntity) ? getSwjgMcBySwjgDm(c.getJcks()) : getSwjgMcBySwjgDm(workflowInspectionHearEntity.getInspectionTaxorg11()));
            c.setAjbh(c.getAjbh() + "\t");
            c.setNsrsbh(c.getNsrsbh() + "\t");
        }
        resPage.setRecords(records);
        return DataResult.success(resPage);
    }

    //[ "1699461822752550914", "1717700015853686785", "1721759807719104514" ]

    /// /////////////////积案管理
    //获取当前登录人所在机关检查科室集合 -公用部分
    @PostMapping("/gy/getcurrentswjgjcks")
    @ResponseBody
   
    public DataResult getcurrentswjgjcks() {
        String currentDeptId = httpSessionService.getCurrentDeptId();
        //获取权限ID
        String rolesId = httpSessionService.getCurrentRolesId();
        String substring = currentDeptId.substring(0, 9);
        LambdaQueryWrapper<DmGySwjgEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(DmGySwjgEntity::getYxbz, "Y");
        queryWrapper.like(DmGySwjgEntity::getSwjgDm, substring + "4");
        List<DmGySwjgEntity> list = dmGySwjgService.list(queryWrapper);
        //判断当前账号是否有全市权限
        if (TsBqUtils.containsAccount(rolesId, TaxConstants.SYSTEM_MGR_ID) || TsBqUtils.containsAccount(rolesId, TaxConstants.SJLDG_ID) || TsBqUtils.containsAccount(rolesId, TaxConstants.JCJLDG_ID) || TsBqUtils.containsAccount(rolesId, TaxConstants.DIRECTO_ID)) {
            list.add(0, createSwjgEntity("qs", "全市"));
            list.add(1, createSwjgEntity("qj", "全局"));
        } else {
            list.add(0, createSwjgEntity("qj", "全局"));
        }
        return DataResult.success(list);
    }


    // 公用 - 全局查询
    @PostMapping("/gy/getcurrentswjgqj")
    @ResponseBody
    public DataResult getcurrentswjgqj() {
        //获取权限ID
        LambdaQueryWrapper<DmGySwjgEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(DmGySwjgEntity::getYxbz, "Y");
        queryWrapper.eq(DmGySwjgEntity::getSwjgbz, "0");
        queryWrapper.eq(DmGySwjgEntity::getJgjcDm, "31");
        queryWrapper.eq(DmGySwjgEntity::getSjswjgDm, "12101000000");
        queryWrapper.orderByAsc(DmGySwjgEntity::getSwjgDm);
        List<DmGySwjgEntity> list = dmGySwjgService.list(queryWrapper);
        return DataResult.success(list);
    }

    // 公用 - 科室查询
    @PostMapping("/gy/getcurrentswjgks")
    @ResponseBody
    public DataResult getcurrentswjgks(@RequestBody DmGySwjgEntity dmGySwjgEntity) {
        //获取权限ID
        LambdaQueryWrapper<DmGySwjgEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(DmGySwjgEntity::getYxbz, "Y");
        queryWrapper.eq(DmGySwjgEntity::getSwjgbz, "1");
        queryWrapper.eq(DmGySwjgEntity::getSjswjgDm, dmGySwjgEntity.getSwjgDm());
        queryWrapper.orderByAsc(DmGySwjgEntity::getSwjgDm);
        List<DmGySwjgEntity> list = dmGySwjgService.list(queryWrapper);
        return DataResult.success(list);
    }

    // 公用 - 检察人员查询
    @PostMapping("/gy/getcurrentswjgry")
    @ResponseBody
    public DataResult getcurrentswjgry(@RequestBody DmGySwjgEntity dmGySwjgEntity) {
        List<DmGySwryEntity> dmGySwjgEntityList = dmGySwryService.queryLajcrytzList(dmGySwjgEntity.getSwjgDm().substring(0, 9));
        for (DmGySwryEntity dmGySwryEntity : dmGySwjgEntityList) {
            dmGySwryEntity.setSwryxm(dmGySwryEntity.getSwryDm() + "|" + dmGySwryEntity.getSwryxm());
        }
        return DataResult.success(dmGySwjgEntityList);
    }

    @PostMapping("/gy/getYljamxSwjgjcks")
    @ResponseBody
    public DataResult getYljamxSwjgjcks() {
        LambdaQueryWrapper<YljamxEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.select(YljamxEntity::getSzdw);
        queryWrapper.groupBy(YljamxEntity::getSzdw);
        queryWrapper.orderByAsc(YljamxEntity::getSzdw);
        List<YljamxEntity> list = yljamxService.list(queryWrapper);
        return DataResult.success(list);
    }

    @PostMapping("/gy/getQtjamxSwjgjcks")
    @ResponseBody
    public DataResult getQtjamxSwjgjcks() {
        LambdaQueryWrapper<QtjamxEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.select(QtjamxEntity::getSsdw);
        queryWrapper.groupBy(QtjamxEntity::getSsdw);
        queryWrapper.orderByAsc(QtjamxEntity::getSsdw);
        List<QtjamxEntity> list = qtjamxService.list(queryWrapper);
        return DataResult.success(list);
    }

    @PostMapping("/gy/getCljamxSwjgjcks")
    @ResponseBody
    public DataResult getCljamxSwjgjcks() {
        LambdaQueryWrapper<CljamxEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.select(CljamxEntity::getSsdw);
        queryWrapper.groupBy(CljamxEntity::getSsdw);
        queryWrapper.orderByAsc(CljamxEntity::getSsdw);
        List<CljamxEntity> list = cljamxService.list(queryWrapper);
        return DataResult.success(list);
    }

    @PostMapping("/gy/queryYljaAjzt")
    @ResponseBody
    public DataResult queryYljaAjzt() {
        String currentDeptId = httpSessionService.getCurrentDeptId();
        //获取权限ID
        String rolesId = httpSessionService.getCurrentRolesId();
        String substring = currentDeptId.substring(0, 9);
        LambdaQueryWrapper<DmGySwjgEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(DmGySwjgEntity::getYxbz, "Y");
        queryWrapper.like(DmGySwjgEntity::getSwjgDm, substring + "4");
        List<DmGySwjgEntity> list = dmGySwjgService.list(queryWrapper);
        //判断当前账号是否有全市权限
        if (TsBqUtils.containsAccount(rolesId, TaxConstants.SYSTEM_MGR_ID) || TsBqUtils.containsAccount(rolesId, TaxConstants.SJLDG_ID) || TsBqUtils.containsAccount(rolesId, TaxConstants.JCJLDG_ID) || TsBqUtils.containsAccount(rolesId, TaxConstants.DIRECTO_ID)) {
            list.add(0, createSwjgEntity("qs", "全市"));
            list.add(1, createSwjgEntity("qj", "全局"));
        } else {
            list.add(0, createSwjgEntity("qj", "全局"));
        }
        return DataResult.success(list);
    }

    private DmGySwjgEntity createSwjgEntity(String dm, String jc) {
        DmGySwjgEntity entity = new DmGySwjgEntity();
        entity.setSwjgDm(dm);
        entity.setSwjgjc(jc);
        return entity;
    }

    @PostMapping("/gy/getallarea")
    @ResponseBody
    public DataResult getallarea() {
        return DataResult.success(t_swjgtmpService.getAllArea());
    }


    @GetMapping("/xazb/tree")
    @ApiOperation(value = "获取所有选案指标大类接口")
    @LogAnnotation(title = "选案指标", action = "获取所有选案指标")
    public DataResult xazbtree() {
        return DataResult.success(attentionService.selectAllXazbTree());
    }

    @PostMapping("/xazb/getXazbMx")
    @ApiOperation(value = "获取选案指标明细接口")
    @LogAnnotation(title = "获取选案指标明细接口", action = "获取选案指标明细接口")
    public DataResult getXazbMx(@RequestBody XazbMx req) {
        return DataResult.success(attentionService.getXazbMxByXadlId(req.getXazbdlid()));
    }

    @PostMapping("/zbxa/zblxList")
    @ApiOperation(value = "指标选案-指标类型列表")
    @LogAnnotation(title = "指标选案-指标类型列表", action = "指标选案-指标类型列表")
    public DataResult zblxList() {
        return DataResult.success(attentionService.zblxList());
    }

    @PostMapping("/zbxa/getZbMxListByZblxId")
    @ApiOperation(value = "获取选案指标明细接口")
    @LogAnnotation(title = "获取选案指标明细接口", action = "获取选案指标明细接口")
    public DataResult getZbMxListByZblxId(@RequestBody XazbMx req) {
        return DataResult.success(attentionService.getXazbMxByXadlId(req.getXazbdlid()));
    }

    @PostMapping("/zbxa/getNsrListByZbmxIds")
    @ApiOperation(value = "根据指标获取纳税人")
    @LogAnnotation(title = "根据指标获取纳税人", action = "根据指标获取纳税人")
    public DataResult getNsrListByZbmxId(@RequestBody XazbNsr req) {
        if (TsBqUtils.isNull(req.getZbmxIds())) {
            Map<String, Object> resData = new HashMap<>();
            resData.put("total", 0);
            return DataResult.success(resData);
        }
        return DataResult.success(attentionService.getNsrListByZbmxId(req));
    }

    @PostMapping("/zbxa/saveXazbNsrList")
    @ApiOperation(value = "保存指标生成的纳税人")
    @LogAnnotation(title = "保存指标生成的纳税人", action = "保存指标生成的纳税人")
    public DataResult saveXazbNsrList(@RequestBody XazbNsrCompleteReq req) {
        String[] zbmxIds = req.getZbmxIds();
        String zbmxIdStr = String.join(",", zbmxIds);
        List<XazbNsrComplete> xazbNsrList = req.getXazbNsrList();
        for (XazbNsrComplete vo : xazbNsrList) {
            vo.setCreateTime(new Date());
            vo.setUpdateTime(null);
            vo.setXazbmxids(zbmxIdStr);
            vo.setResname(req.getResname());
            vo.setXafaid(req.getXafaId());
            vo.setLrrDm(httpSessionService.getCurrentUsername());
        }
        if (xazbNsrCompleteService.saveBatch(xazbNsrList)) {
            UpdateWrapper<ZbxaXafaEntity> updateWrapper = new UpdateWrapper<>();
            updateWrapper.eq("id", req.getXafaId()); // 设置条件，例如根据 id 更新
            ZbxaXafaEntity entity = new ZbxaXafaEntity();
            entity.setId(req.getXafaId());
            entity.setStatus("3");
            entity.setUpdateTime(new Date());
            zbxaXafaService.update(entity, updateWrapper);
            return DataResult.success();
        } else {
            return DataResult.fail("保存纳税人失败");
        }
    }

    @PostMapping("/zbxansrcx")
    @ApiOperation(value = "指标选案纳税人查询")
    @LogAnnotation(title = "指标选案纳税人查询", action = "指标选案纳税人查询")
    @SuppressWarnings({"rawtypes"})
    public DataResult zbxansrcx(@RequestBody AjcxCondition req) throws ParseException {
        Page resPage = xazbNsrCompleteService.zbxansrcx(req);
        return DataResult.success(resPage);
    }

    @PostMapping("/ajyj/tableFirstLevel")
    @ResponseBody
    public DataResult ajyjTableFirstLevel(@RequestBody SelectchiefReqVo req) {
        return DataResult.success(attentionService.ajyjTableFirstLevel(req.getSwjgDm()));
    }

    @PostMapping("/ajyj/detailData")
    @ResponseBody
    public DataResult detailData(@RequestBody InspectRequestData req) {
        return DataResult.success(attentionService.getCqyjDetailDataForXzs(req));
    }

    @PostMapping("/ajyj/chartData")
    @ResponseBody
    public DataResult chartData() {
        return DataResult.success(attentionService.chartData());
    }


    @PostMapping("/zbxazdhyzd/list")
    @ApiOperation(value = "分页获取重点行业字典接口")
    @LogAnnotation(title = "重点行业字典", action = "分页获取重点行业字典")
    @SuppressWarnings({"unchecked", "rawtypes"})
    public DataResult zbxazdhyzdList(@RequestBody ZbxaIndustryEntity vo) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        Page page = new Page(vo.getPage(), vo.getLimit());
        LambdaQueryWrapper<ZbxaIndustryEntity> queryWrapper = Wrappers.lambdaQuery();
        if (!StringUtils.isEmpty(vo.getStatus())) {
            queryWrapper.eq(ZbxaIndustryEntity::getStatus, vo.getStatus());
        }
        queryWrapper.eq(ZbxaIndustryEntity::getSwjgDm, swjgDmTmp + "00");
        queryWrapper.orderByAsc(ZbxaIndustryEntity::getCreateTime);
        return DataResult.success(zbxaIndustryService.page(page, queryWrapper));
    }

    @PostMapping("/zbxazdhyzd/deleted/{id}")
    @ApiOperation(value = "删除重点行业接口")
    @LogAnnotation(title = "重点行业", action = "删除重点行业")
    public DataResult zbxazdhyzdDeleted(@PathVariable("id") String id) {
        zbxaIndustryService.deletedCase(id);
        return DataResult.success();
    }

    @GetMapping("/zbxazdhyzd/detail/{id}")
    @ApiOperation(value = "查询重点行业详情接口")
    @LogAnnotation(title = "重点行业详情", action = "查询重点行业详情")
    public DataResult zbxazdhyzdDetail(@PathVariable("id") String id) {
        return DataResult.success(zbxaIndustryService.detailInfo(id));
    }


    @PostMapping("/zbxazdhyzd/add")
    @ApiOperation(value = "新增重点行业接口")
    @LogAnnotation(title = "重点行业", action = "新增重点行业")
    public DataResult zbxazdhyzdAdd(@RequestBody @Valid ZbxaIndustryEntity vo) {
        String currentSwjgDm = httpSessionService.getCurrentDeptNo();
        String swjgDmTmp = currentSwjgDm.substring(0, 9);
        vo.setSwjgDm(swjgDmTmp + "00");
        vo.setLrrDm(httpSessionService.getCurrentUserId());
        zbxaIndustryService.addCase(vo);
        return DataResult.success();
    }

    @PostMapping("/zbxazdhyzd/update")
    @ApiOperation(value = "更新重点行业接口")
    @LogAnnotation(title = "重点行业", action = "更新重点行业")
    public DataResult zbxazdhyzdUpdate(@RequestBody ZbxaIndustryEntity vo) {
        if (StringUtils.isEmpty(vo.getId())) {
            return DataResult.fail("id不能为空");
        }
        zbxaIndustryService.updateCase(vo);
        return DataResult.success();
    }


    @PostMapping("/zbxaXafa/getNsrListByXafaId")
    @ApiOperation(value = "根据选案方案获取纳税人")
    @LogAnnotation(title = "根据选案方案获取纳税人", action = "根据选案方案获取纳税人")
    @SuppressWarnings({"unchecked", "rawtypes"})
    public DataResult getNsrListByXafaId(@RequestBody ZbxaXafaEntity req) {
        Page page = new Page(req.getPage(), req.getLimit());
        LambdaQueryWrapper<XazbNsrComplete> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(XazbNsrComplete::getXafaid, req.getId());
        queryWrapper.orderByDesc(XazbNsrComplete::getCreateTime);
        Page resPage = xazbNsrCompleteService.page(page, queryWrapper);
        List<XazbNsrComplete> records = resPage.getRecords();
        for (XazbNsrComplete vo : records) {
            String lrrDm = vo.getLrrDm();
            DmGySwryEntity zcSwry = dmGySwryService.getSwry(lrrDm);
            String swryXm = zcSwry.getSwryxm();
            vo.setLrrDm(swryXm + "|" + lrrDm);
        }
        return DataResult.success(resPage);
    }


    @PostMapping("/jasjqc/deleted/{id}")
    @ApiOperation(value = "清除积案数据接口")
    @LogAnnotation(title = "清除积案数据接口", action = "清除积案数据接口")
    public DataResult jasjqc(@PathVariable("id") String id) {
        //1是积案状态 2是预计完成时间
        if ("1".equals(id)) {
            UpdateWrapper<JaajxxStatuschangeEntity> updateWrapper = new UpdateWrapper<>();
            updateWrapper.eq("SWJG_DM", httpSessionService.getCurrentDeptId().substring(0, 9) + "00");
            updateWrapper.set("YXBZ", "N"); // 设置要更新的字段和新值
            updateWrapper.set("XGR_DM", httpSessionService.getCurrentUserId());
            updateWrapper.set("UPDATE_TIME", new Date());
            // 执行更新操作
            jaajxxStatuschangeMapper.update(null, updateWrapper);
        } else if ("2".equals(id)) {
            UpdateWrapper<JaajxxYjqlsjEntity> updateWrapper = new UpdateWrapper<>();
            updateWrapper.likeRight("JCKS", httpSessionService.getCurrentDeptId().substring(0, 9));
            updateWrapper.set("ISDELETE", "Y"); // 设置要更新的字段和新值
            updateWrapper.set("XGR_DM", httpSessionService.getCurrentUserId());
            updateWrapper.set("UPDATE_TIME", new Date());
            // 执行更新操作
            jaajxxYjqlsjMapper.update(null, updateWrapper);
        }
        return DataResult.success();
    }


    @PostMapping("/jaajxxYjqlsj/importByajbhYjqlsj")
    @ApiOperation(value = "导入excel积案预计清理时间")
    @LogAnnotation(title = "导入excel积案预计清理时间", action = "导入excel积案预计清理时间")
    public DataResult importByajbhYjqlsj(@RequestParam(value = "file") MultipartFile file) throws IOException, ParseException {
        String[] allJaCaseIds = {"1753235180390457346", "4A83C7C7819843A6BC439E31E864FDDB", "1753235137625333761", "1753235212262973441",
                "1753235156424204289", "CD7144F1D8EF4F2A807B56BB6EF836C3", "1753235199331934210", "1753235225022046209"};
        LambdaQueryWrapper<CaseAjxxRelation> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.in(CaseAjxxRelation::getCaseId, Arrays.asList(allJaCaseIds));
        List<CaseAjxxRelation> allJaAjxxDataList = caseAjxxRelationService.list(queryWrapper);
        //取所有积案的案件编号
        List<String> jaajbhs = new ArrayList<>();
        for (CaseAjxxRelation obj : allJaAjxxDataList) {
            jaajbhs.add(obj.getAjbh());
        }

        ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
        List<List<Object>> allAjbhList = reader.read(1, reader.getRowCount());
        List<String> importajbhs = new ArrayList<>();
        List<Map<String, String>> okMaps = new ArrayList<>();
        Map<String, String> objMap;
        for (List<Object> objects : allAjbhList) {
            importajbhs.add(String.valueOf(objects.get(0)).trim());
            objMap = new HashMap<>();
            objMap.put(String.valueOf(objects.get(0)).trim(), String.valueOf(objects.get(1)).trim());
            okMaps.add(objMap);
        }
        List<String> notexistsAjbhs = importajbhs.stream()
                .filter(item -> !jaajbhs.contains(item))
                .collect(Collectors.toList());
        //存在的listMap
        List<String> existsAjbhs = importajbhs.stream()
                .filter(jaajbhs::contains)
                .collect(Collectors.toList());
        List<Map<String, Object>> ajxxList = caseAjxxRelationService.getAjxxByAjbhs(existsAjbhs);
        int importCount = jaajxxYjqlsjService.importJaajxxYjqlsjDatas(ajxxList, okMaps, existsAjbhs);
        Map<String, Object> res = new HashMap<>();
        res.put("importCount", importCount);
        res.put("notexistsAjbhs", notexistsAjbhs);
        return DataResult.success(res);
    }

    @PostMapping("/jaajxxJaxcyy/importByajbhJaxcyy")
    @ApiOperation(value = "导入excel案件形成原因")
    @LogAnnotation(title = "导入excel案件形成原因", action = "导入excel案件形成原因")
    public DataResult importByajbhJaxcyy(@RequestParam(value = "file") MultipartFile file) throws IOException, ParseException {
        String[] allJaCaseIds = {"1753235180390457346", "4A83C7C7819843A6BC439E31E864FDDB", "1753235137625333761", "1753235212262973441",
                "1753235156424204289", "CD7144F1D8EF4F2A807B56BB6EF836C3", "1753235199331934210", "1753235225022046209"};
        LambdaQueryWrapper<CaseAjxxRelation> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.in(CaseAjxxRelation::getCaseId, Arrays.asList(allJaCaseIds));
        List<CaseAjxxRelation> allJaAjxxDataList = caseAjxxRelationService.list(queryWrapper);
        //取所有积案的案件编号
        List<String> jaajbhs = new ArrayList<>();
        for (CaseAjxxRelation obj : allJaAjxxDataList) {
            jaajbhs.add(obj.getAjbh());
        }

        ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
        List<List<Object>> allAjbhList = reader.read(1, reader.getRowCount());
        List<String> importajbhs = new ArrayList<>();
        List<Map<String, String>> okMaps = new ArrayList<>();
        Map<String, String> objMap;
        for (List<Object> objects : allAjbhList) {
            importajbhs.add(String.valueOf(objects.get(0)).trim());
            objMap = new HashMap<>();
            objMap.put(String.valueOf(objects.get(0)).trim(), String.valueOf(objects.get(1)).trim());
            okMaps.add(objMap);
        }
        List<String> notexistsAjbhs = importajbhs.stream()
                .filter(item -> !jaajbhs.contains(item))
                .collect(Collectors.toList());
        //存在的listMap
        List<String> existsAjbhs = importajbhs.stream()
                .filter(jaajbhs::contains)
                .collect(Collectors.toList());
        List<Map<String, Object>> ajxxList = caseAjxxRelationService.getAjxxByAjbhs(existsAjbhs);
        int importCount = jaajxxJaxcyyService.importJaajxxJaxcyyDatas(ajxxList, okMaps, existsAjbhs);
        Map<String, Object> res = new HashMap<>();
        res.put("importCount", importCount);
        res.put("notexistsAjbhs", notexistsAjbhs);
        return DataResult.success(res);
    }

    @PostMapping("/zdgz/queryJtjbTable")
    @ApiOperation(value = "查询静态建表页面")
    @LogAnnotation(title = "查询静态建表页面", action = "查询静态建表页面")
   
    public DataResult queryJtjbTable(@RequestBody JtjbEntity jtjbEntity) {
        // 创建分页对象，明确指定泛型类型为 JtjbEntity
        Page<JtjbEntity> page = new Page<>(jtjbEntity.getPage(), jtjbEntity.getLimit());
        // 创建 LambdaQueryWrapper，明确指定泛型类型为 JtjbEntity
        LambdaQueryWrapper<JtjbEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JtjbEntity::getYxbz, Constants.AJZT_LX_Y);  // 条件：Yxbz 等于常量 AJZT_LX_Y
        queryWrapper.orderByDesc(JtjbEntity::getLrrq);  // 排序：按 Lrrq 字段降序排序
        // 调用分页查询服务，返回结果
        return DataResult.success(jtjbService.page(page, queryWrapper));
    }

    @PostMapping("/zdgz/queryAllJtjb")
    @ApiOperation(value = "查询静态建表页面")
    @LogAnnotation(title = "查询静态建表页面", action = "查询静态建表页面")
   
    public DataResult queryAllJtjb() {
        LambdaQueryWrapper<JtjbEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JtjbEntity::getJbzt, Constants.AJZT_LX_YTZ);  // 条件：Yxbz 等于常量 AJZT_LX_Y
        queryWrapper.orderByDesc(JtjbEntity::getLrrq);  // 排序：按 Lrrq 字段降序排序
        List<JtjbEntity> jtjbEntityList = jtjbService.list(queryWrapper);
        return DataResult.success(jtjbEntityList);
    }

    @PostMapping("/zdgz/delJtjb")
    @ApiOperation(value = "删除静态建表页面")
    @LogAnnotation(title = "删除静态建表页面", action = "删除静态建表页面")
   
    public DataResult delJtjb(@RequestBody JtjbEntity jtjbEntity) {
        Boolean result = jtjbService.removeById(jtjbEntity);
        return DataResult.success(result);
    }

    @PostMapping("/zdgz/saveJtjb")
    @ApiOperation(value = "保存静态建表页面")
    @LogAnnotation(title = "保存静态建表页面", action = "保存静态建表页面")
   
    public DataResult saveJtjb(@RequestBody JtjbEntity jtjbEntity) {
        Boolean result = jtjbService.saveJtjb(jtjbEntity);
        return DataResult.success(result);
    }

    @PostMapping("/attentionMgr/queryCljdsTable")
    @ApiOperation(value = "案件管理-处理决定书清册")
    @LogAnnotation(title = "案件管理-处理决定书清册", action = "查询处理决定书清册表格数据")
    public DataResult queryCljdsTable(@RequestBody AjglCljdsqcEntity ajglCljdsqcEntity) throws ParseException {
        IPage<AjglCljdsqcEntity> resPage = ajglCljdsqcService.queryCljdsTable(ajglCljdsqcEntity);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/exportCljdsTable")
    @ApiOperation(value = "案件管理-处理决定书清册")
    @LogAnnotation(title = "案件管理-处理决定书清册", action = "查询处理决定书清册表格数据")
    public DataResult exportCljdsTable(@RequestBody AjglCljdsqcEntity ajglCljdsqcEntity) throws ParseException {
        List<AjglCljdsqcEntity> ajglCljdsqcEntityList = ajglCljdsqcService.exportCljdsTable(ajglCljdsqcEntity);
        return DataResult.success(ajglCljdsqcEntityList);
    }

    @PostMapping("/attentionMgr/queryCfjdsTable")
    @ApiOperation(value = "案件管理-处罚决定书清册")
    @LogAnnotation(title = "案件管理-处罚决定书清册", action = "查询处罚决定书清册表格数据")
    public DataResult queryCfjdsTable(@RequestBody AjglCfjdsqcEntity ajglCfjdsqcEntity) throws ParseException {
        IPage<AjglCfjdsqcEntity> resPage = ajglCfjdsqcService.queryCfjdsTable(ajglCfjdsqcEntity);
        return DataResult.success(resPage);
    }


    @PostMapping("/attentionMgr/queryCfjdsTableByAjbh")
    @ApiOperation(value = "案件管理-根据案件编号查询处罚决定书清册")
    @LogAnnotation(title = "案件管理-根据案件编号查询处罚决定书清册", action = "根据案件编号查询处罚决定书清册表格数据")
    public DataResult queryCfjdsTableByAjbh(@RequestBody String jcajbh) {
        if (jcajbh == null) {
            throw new BusinessException("传递的案件编号为空");
        }
        AjglCfjdsqcEntity resPage = ajglCfjdsqcService.queryCfjdsTableByAjbh(jcajbh);
        DmGySwjgEntity swjg = dmGySwjgService.getSwjgDm(resPage.getSwjgDm());
        resPage.setSwjgDm(swjg.getSwjgmc());
        DmGySwryEntity swry = dmGySwryService.getSwry(resPage.getLrrDm());
        resPage.setLrrDm(swry.getSwryxm());
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/exportCfjdsTable")
    @ApiOperation(value = "案件管理-处罚决定书清册")
    @LogAnnotation(title = "案件管理-处罚决定书清册", action = "查询处罚决定书清册表格数据")
    public DataResult exportCfjdsTable(@RequestBody AjglCfjdsqcEntity ajglCfjdsqcEntity) throws ParseException {
        List<AjglCfjdsqcEntity> resPage = ajglCfjdsqcService.exportCfjdsTable(ajglCfjdsqcEntity);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/queryJctzsTable")
    @ApiOperation(value = "案件管理-检查通知书清册")
    @LogAnnotation(title = "案件管理-检查通知书清册", action = "查询检查通知书清册")
    public DataResult queryJctzsTable(@RequestBody AjglJctzsqcEntity ajglJctzsqcEntity) throws ParseException {
        IPage<AjglJctzsqcEntity> resPage = ajglJctzsqcService.queryJctzsTable(ajglJctzsqcEntity);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/exportJctzsTable")
    @ApiOperation(value = "案件管理-检查通知书清册")
    @LogAnnotation(title = "案件管理-检查通知书清册", action = "查询检查通知书清册")
    public DataResult exportJctzsTable(@RequestBody AjglJctzsqcEntity ajglJctzsqcEntity) throws ParseException {
        List<AjglJctzsqcEntity> resPage = ajglJctzsqcService.exportJctzsTable(ajglJctzsqcEntity);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/queryClcfjdbbTable")
    @ApiOperation(value = "审理-处理处罚决定书报表")
    @LogAnnotation(title = "审理-处理处罚决定书报表", action = "分页查询处理处罚决定书报表")
    public DataResult queryClcfjdbbTable(@RequestBody ClcfjdbbEntity clcfjdbbEntity) throws ParseException {
        IPage<ClcfjdbbEntity> resPage = clcfjdbbService.queryClcfjdbbTable(clcfjdbbEntity);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/exportClcfjdbbTable")
    @ApiOperation(value = "审理-处理处罚决定书报表")
    @LogAnnotation(title = "审理-处理处罚决定书报表", action = "导出处理处罚决定书报表")
    public DataResult exportClcfjdbbTable(@RequestBody ClcfjdbbEntity clcfjdbbEntity) throws ParseException {
        List<ClcfjdbbEntity> clcfjdbbEntityList = clcfjdbbService.exportClcfjdbbTable(clcfjdbbEntity);
        return DataResult.success(clcfjdbbEntityList);
    }

    @PostMapping("/attentionMgr/saveClcfjdbb")
    @ApiOperation(value = "审理-处理处罚决定书报表")
    @LogAnnotation(title = "审理-处理处罚决定书报表", action = "处理处罚决定书报表")
   
    public DataResult saveClcfjdbb(@RequestBody ClcfjdbbEntity clcfjdbbEntity) {
        clcfjdbbEntity.setTbbz(Constants.AJZT_LX_Y);
        return DataResult.success(clcfjdbbService.updateById(clcfjdbbEntity));
    }


    @PostMapping("/attentionMgr/queryAjzxqk")
    @ApiOperation(value = "案件管理-案件执行情况查询")
    @LogAnnotation(title = "案件管理-案件执行情况查询", action = "案件执行情况查询")
    public DataResult queryAjzxqk(@RequestBody JcAjzxqkEntity jcAjzxqkEntity) throws ParseException {
        IPage<JcAjzxqkEntity> resPage = jcAjzxqkService.queryAjzxqkList(jcAjzxqkEntity);
        return DataResult.success(resPage);
    }

    @PostMapping("/attentionMgr/queryCfqkcx")
    @ApiOperation(value = "审理环节-处罚情况情况查询")
    @LogAnnotation(title = "审理环节-处罚情况情况查询", action = "处罚情况情况查询")
    public DataResult queryCfqkcx(@RequestBody JcCfqkcxEntity jcCfqkcxEntity) throws ParseException {
        IPage<JcCfqkcxEntity> resPage = jcCfqkcxService.queryCfqkcxList(jcCfqkcxEntity);
        return DataResult.success(resPage);
    }


    @ApiOperation(value = "重点关注-查询检举案件信息")
    @LogAnnotation(title = "重点关注", action = "查询检举案件信息")
    @PostMapping("/attentionMgr/queryJjajList")
    @ResponseBody
   
    public DataResult queryJjajList(@RequestBody JcJjajEntity jcJjajEntity) throws ParseException {
        IPage<JcJjajEntity> iPage = jcJjajService.queryJjajxxList(jcJjajEntity);
        return DataResult.success(iPage);
    }

    @ApiOperation(value = "重点关注-导出检举案件信息")
    @LogAnnotation(title = "重点关注", action = "导出检举案件信息")
    @PostMapping("/attentionMgr/exportJjajList")
    @ResponseBody
   
    public DataResult exportJjajList(@RequestBody JcJjajEntity jcJjajEntity) throws ParseException {
        List<JcJjajEntity> jcJjajEntityList = jcJjajService.exportJjajList(jcJjajEntity);
        return DataResult.success(jcJjajEntityList);
    }

    @ApiOperation(value = "重点关注-指标查询")
    @LogAnnotation(title = "重点关注", action = "指标查询")
    @PostMapping("/attentionMgr/queryZbcxTable")
    @ResponseBody
   
    public DataResult queryZbcxTable(@RequestBody ZbcxEntity zbcxEntity) throws ParseException {
        // 调用 Service 进行分页查询
        Map<String, Object> resMap = zbcxService.queryZbcxTable(zbcxEntity);
        return DataResult.success(resMap); // 返回 Map 结果
    }


}